Method for realizing color interpolation of value correction of exceptional points

ABSTRACT

A method for realizing color interpolation of the value correction of exceptional points is disclosed. The method includes the following steps: the certain point in the BAYER matrix is set as the center to establish a 5×5 interpolation matrix, in which each point is represented by one known color and two unknown colors and the known color of the center is R or B; the known color of the center point is corrected based on the known color value of the known points in the matrix with the same color as that of the center point; the color change trends along both row and column directions in which the center point is located are judged to select the row direction or column direction in which the center as the reference direction of the interpolation calculation; and the two color values of the center point are interpolated.

FIELD OF THE INVENTION

The present invention relates to a method for color interpolation, and more specially to a method that is designed to realize value correction of exceptional points along with color interpolation for a Bayer color matrix obtained during the process of digital image processing.

BACKGROUND OF THE INVENTION

During the process of digital image processing, color interpolation must be carried out for the image obtained by a BAYER color matrix, so as to recover the image colors. Most existing methods realize interpolation for the pixel points with spatial correlation or color correlation. However, with such methods, if any exceptional point occurs in the BAYER matrix, the exceptionality will diffuse to the interpolation for the surrounding points, and thereby strongly influences the result of color interpolation; in addition, utilizing a specific method solely often results in image blur on the boundaries or pseudo colors in fine structures, which has adverse effect to the result of color interpolation.

SUMMARY OF THE INVENTION

The object of the present invention is to provide a method for color interpolation that can realize value correction of exceptional points in an image and thereby improves image quality.

The object of the present invention is attained as follows: the color interpolation method for realizing value correction of exceptional points comprises the following steps:

1) Establishing a matrix for color interpolation: a point at which interpolation is to be carried out is set as the center point to establish in which each point is represented by one known color and two unknown colors (the three colors are R, G, and B), and the known color of the center point is R or B;

2) correcting the known color value of the center point: correct the known color value of the center point is corrected based on the relationship of difference of the known color value of points in the matrix with the same known color as that of the center point;

3) determining a reference: color change trends along row and column directions in which the center point is located are judged, and the row or column direction in which the center point is located is selected as a reference direction for the interpolation calculation;

4) interpolating for the two unknown color values of the center point: average values of points with the unknown colors of the center point as the known color of the points in the reference direction are taken as the estimated values for the unknown colors of the center point, and the estimated values are corrected with difference values between the known color values of another two points with the same known color as that of the center point in the reference direction and the known color value of the center point, so as to obtain interpolation results for the two unknown colors of the center point.

In above step 2), a principle for the correction is as follows: if the known color value of the center point is higher by a preset value than the known color values of all surrounding points with the same known color as that of the center point or lower by a preset value than the known color values of all the surrounding points, replace the known color value of the center point with the average value of the known color values of the surrounding points; otherwise the known color value of the center point is maintained.

The color interpolation method for realizing value correction of exceptional points comprises the following steps:

1) establishing a Bayer matrix for color interpolation: a point at which interpolation is to be carried out is set as a center point to establish a 5×5 Bayer matrix, in which each point is represented by one known color and two unknown colors, the three colors being R, G, and B, and the known color of the center point is G;

2) correcting the known color value of the center point: the known color value of the center point is corrected based on the relationship of difference of the known color value of points in the matrix with the same known color as that of the center point;

3) correcting the known color value of the points surrounding to the center point: the known color values of two points with B as known color surrounding to the center point and two points with R as known color surrounding to the center point;

4) interpolating for two unknown color values of the center point: average values of the corrected known color values of the two points with R or B as known color surrounding to the center point are respectively taken as estimated values for color R or B of the center point, and the estimated values are corrected with difference values between the known color value of the center point and the known color values of the surrounding points, so as to obtain the values of color R and B of the center point, respectively.

In above step 2) and 3), the principle for the correction calculation is: if the known color value of a certain point is higher by a preset value than the known color values of all surrounding points with the same known color as that of the center point, and the difference value between the known color value of the point and the average value of the known color values of the surrounding points is also higher than the preset value, then the known color value of the point is replaced with the average value of the known color values of the surrounding points; otherwise the known color value of the point is maintained.

Compared to the prior art, the present invention has the following advantages: the present invention can eliminate exceptional points in an image, prevent diffusion of exceptional color values in the interpolation process, and thereby refine image details and colors; in addition, it can enhance image boundaries and make the image on the boundaries clearer, and therefore prevent pseudo colors.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 and FIG. 4 show a Bayer matrix with a Blue center point and a Bayer matrix with a Red center point;

FIG. 2 and FIG. 3 show a Bayer matrix with a Green center point, respectively;

FIG. 5 is a flow diagram of the present invention.

DETAILED DESCRIPTION OF THE EMBODIMENTS

Please see FIG. 1-FIG. 5, the color interpolation method for realizing value correction for exceptional points in the present invention utilizes a 5×5 Bayer matrix to realize interpolation in the image. The 5×5 Bayer matrix may be in either of the following two cases: 1) the known color of the center point is Blue (as shown in FIG. 1) or Red (as shown in FIG. 4), and the green points are in the same positions; 2) the known color of the center point is Green, and the positions of Red points and the positions of Blue points are interchangeable, as shown in FIG. 2 and FIG. 3.

In the first case, the interpolation method comprises the following steps:

1) establishing a matrix for color interpolation: a point at which interpolation is to be carried out is set as the center point to establish a 5×5 Bayer matrix, in which each point is represented by one known color and two unknown colors, the three colors being R, G, and B, and the known color of the center point is R or B;

2) correcting the known color value of the center point: the known color value of the center point is corrected based on the relationship of difference of the known color value of points in the matrix with the same known color as that of the center point;

3) determining a reference: the color change trends along row and column directions in which the center point is located are judged, and the row or column direction in which the center point is located as the reference direction for interpolation calculation is selected;

4) interpolating for the two unknown color values of the center point: average values of points with the unknown colors of the center point as the known color of the points in the reference direction are taken as the estimated values for the unknown colors of the center point, and the estimated values are corrected with difference values between the known color values of another two points with the same known color as that of the center point in the reference direction and the known color value of the center point, so as to obtain the interpolation result for the two unknown colors of the center point.

In above step 2), the principle for the correction calculation is as follows: if the known color value of the center point is higher by a preset value (Th) than the known color values of all surrounding points that have the same known color as the center point or lower by the preset value (Th) than the known color values of all surrounding points with the same known color as that of the center point, the known color value of the center point is replaced with the average value of the known color values of the surrounding points; otherwise keep the known color value of the center point. The correction process is as follows:

Ra=⅛*(R11+R13+R15+R31+R35+R51+R53+R55);

Rb=R33+Th;

Rs=R33−Th;

If R11>Rb, R13>Rb, R15>Rb, R31>Rb, R35>Rb, R51>Rb, R53>Rb, and R55>Rb are all true, or R11<Rs, R13<Rs, R15<Rs, R31<Rs, R35<Rs, R51<Rs, R53<Rs, and R55<Rs are all true, then R33=Ra; otherwise R33=R33.

After the correction for point R33 is completed, two parameters H1 and V1 can be calculated and obtained:

H1=|G32−G34|+|R33−R31+R33−R35|

V1=|G23−G43|+|R33−R13+R33−R53|

The two parameters H1 and V1 describe the color chance trends along column and row directions in which the center point is located, respectively; the color change trend can be described in two aspects: the difference value between surrounding Green points in row and column directions (i.e., |G32-G34| and |G23-G43|, respectively), and the difference value between the actual value of Red R33 of the center point and the average value of surrounding points ((R31+R35)/2 and (R13+R53)/2) in row and column directions (due to the fact that the contribution of Green is the highest in the contribution of colors to brightness, the weight of Green difference is higher than the weight of Red difference). In the direction in which the parameters are smaller, the color values are more authentic to reflect the brightness change trend; therefore, the color values that have brightness change trend smoother that varies less brightness change trend can be used in the interpolation calculation.

According to above deduction, in the case that the center point is Red, as shown in FIG. 4, the interpolation calculations for G33 and B33 are as follows:

If H1<V1:

G33=½*(G32+G34)+¼*(R33−R31+R33−R35);

B33=¼*(B22+B24+B42+B44)+¼*(R33−½*(R13+R53)+½*(G32+G34)−½*(G23+G43));

If H1>V1:

G33=½*(G23+G43)+¼*(R33−R13+R33−R53);

B33=¼*(B22+B24+B42+B44)+¼*(R33−½*(R31+R35)+½*(G23+G43)−½*(G32+G34));

If H1>V1:

G33=¼*(G32+G34+G23+G43)+⅛*(R33−R31+R33−R35+R33−R13+R33−R53);

B33=¼*(B22+B24+B42+B44)+⅛*(R33−R31+R33−R35+R33−R13+R33−R53);

In above interpolation method, for G33 and B33, the interpolation calculation is carried out for the values of unknown colors with the known color values that reflects brightness change trend that varies less, which comprises two parts: carry out estimation with the average value of surrounding points with the same known color in row or column direction in which the brightness change trend v; carry out correction for the estimated value with the difference between the center point and the surrounding points that have the same known color and reflect brightness change trend that varies less, so as to obtain a color interpolation result that is closer to the actual value. In the interpolation calculation for B33 and G33, since the difference in Green color has higher weight than the difference in Red color in terms of the contribution to color brightness, the deviation in green color in row or column must be considered in the interpolation process.

In the second case, the interpolation method comprises the following steps;

1) establishing a Bayer matrix for color interpolation: a point at which interpolation is to be carried out is set as a center point to establish a 5×5 Bayer matrix, in which each point is represented by one known color and two unknown colors, the three colors being R, G, and B, and the known color of the center point is G;

2) correcting the known color value of the center point: the known color value of the center point is corrected based on the relationship of difference of the known color value of points in the matrix with the same known color as that of the center point;

3) correcting the known color value of points surrounding to the center point: the known color value of two points with B as known color surrounding to the center point and two points with R as known color surrounding to the center point are corrected;

4) interpolating for two unknown color values of the center point: average values of the corrected known color values of the two points with R or B as known color surrounding to the center point are respectively taken as estimated values for color R or B of the center point, and the estimated values are corrected with difference values between the known color value of the center point and the known color values of the surrounding points, so as to obtain the values of color R and B of the center point, respectively.

Please see FIG. 3. For step 2), the principle for correction is as follows: if the difference value between the known color values of G33 and the eight surrounding points with the same known color as that of the center point is higher than parameter Th and the difference between G33 and the average value of the known color values of the eight points is also higher than Th, it is deemed that G33 is exceptional, and the original value must be replaced with the average value of the eight surrounding points. The calculation process is as follows:

Ga=⅛*(G13+G22+G24+G31+G35+G42+G44+G53);

If |G33−G13|>Th, |G33−G22|>Th, |G33−G24|>Th, |G33−G31|>Th, |G33−G35|>Th, |G33−G42|>Th, |G33−G44|>Th, |G33−G53|>Th along with |G33−Ga|>Th, then G33=Ga.

After G33 is corrected, R32, R34 (i.e., the reference point for R33), B23, and B43 (i.e., the reference point for B33) must be corrected, in the same principle as the correction calculation for R33 (or B33) in the first case, in order to reduce the adverse effect of exceptionality of reference point to the interpolation calculation, since there are only two reference points for interpolation calculation evaluation for R33 (or B33). The reference points with the same known color around R32 are R12, R14, R34, R52, and R54; the reference points with the same known color around R34 are R12, R14, R32, R52, and R54; the reference points with the same known color around B23 are B21, B25, B41, B43, and B45; the reference points with the same known color around B43 are B21, B23, B25, B41, and B45. In the view of the position relationship between the points and the corrected points, the weights of the points are slightly different to each other. The weighted average value equations are as follows:

Ral=⅛*(2*R12+R14+2*R34+2*R52+R54)

Rar=⅛*(R12+2*R14+2*R32+R52+2*R54)

Bau=⅛*(2*R21+2*R25+R41+2*R43+R45)

Bad=⅛*(R21+2*R23+R25+2*R41+2*R45)

In the same principle for correction for G33, if the difference values between R32 (or R34, B23, B43) and the five reference points with the same color around R32 (or R34, B23, B43) are higher than parameter Th and the weighted average difference values between R32 (or R34, B23, B43) and the five points are higher than Th, it is deemed that R32 (or R34, B23, B43) is exceptional, and the original value must be replaced with the weighted average value; otherwise the original value can be used.

After the four points are corrected, reference points without exceptionality can be obtained for interpolation calculation. The interpolation employs the basic point for reference in the evaluation and employs the values of Green color for compensation and correction. The interpolation equations are as follows:

R33=½*(R32+R34)+¼*(G33−Rl+G33−Rr)

B33=½*(B23+R43)+¼*(G33−Bu+G33−Bd);

Wherein:

Rl=¼*(G33+G31+G22+G42);

Rr=¼*(G33+G35+G24+G44);

Bu=¼*(G33+G13+G22+G24);

Bd=¼*(G33+G53+G42+G44);

It is seen from above equations: the interpolation estimation also comprises two parts: generating an estimated value with the average value of two surrounding points after correction, and then correcting the estimated value with the difference in Green color between the center point and the surrounding Green points, so as to obtain the final color interpolation result. Other interpolation methods that make Green point as center point is similar to the interpolation method described above, only the positions of Red and Blue colors must be exchanged. 

1. A method for realizing color interpolation of value correction of exceptional points, the method comprises: 1) establishing a matrix for color interpolation: a point at which interpolation is to be carried out is set as a center point to establish a 5×5 Bayer matrix, in which each point is represented by one known color and two unknown colors, the three colors being R, G, and B, and the known color of the center point is R or B; 2) correcting the known color value of the center point: the known color value of the center point is corrected based on the relationship of difference of the known color value of points in the matrix with the same known color as that of the center point; 3) determining a reference: color change trends along row and column directions in which the center point is located are judged, and the row or column direction in which the center point is located is selected as a reference direction for interpolation calculation; 4) interpolating for the two unknown color values of the center point: average values of points with the unknown colors of the center point as the known color of the points in the reference direction are taken as the estimated values for the unknown colors of the center point, and the estimated values are corrected with difference values between the known color values of another two points with the same known color as that of the center point in the reference direction and the known color value of the center point, so as to obtain interpolation results for the two unknown colors of the center point.
 2. The method for realizing color interpolation of value correction of exceptional points according to claim 1, wherein, in step 2), a principle for correction is as follows: if the known color value of the center point is higher or lower by a preset value than the known color values of surrounding points with the same known color as that of the center point, the known color value of the center point is replaced with the average value of the known color values of the surrounding points; otherwise the known color value of the center point is maintained.
 3. The method for realizing color interpolation of value correction of exceptional points according to claim 1, wherein in the step 3), the row direction or column direction along which the color change trend varies less is taken as the reference direction for the interpolation calculation.
 4. The method for realizing color interpolation of value correction of exceptional points according to claim 3, wherein if the known color of the center point is R, then in the step 3): the color change trend along row direction is: H1=|G32−G34|+|R33−R31+R33−R35|, and the color change trend along column direction is: V1=|G23−G43|+|R33−R13+R33−R53|, in the step 4): if H1<V1, then G33=½*(G32+G34)+¼*(R33−R31+R33−R35); B33=¼*(B22+B24+B42+B44)+¼*(R33−½*(R13+R53)+½*(G32+G34)−½*(G23+G43)); if H1>V1, then G33=½*(G23+G43)+¼*(R33−R13+R33−R53); B33=¼*(B22+B24+B42+B44)+¼*(R33−½*(R31+R35)+½*(G23+G43)−½*(G32+G34)); if H1=V1, then: G33=¼*(G32+G34+G23+G43)+⅛*(R33−R31+R33−R35+R33−R13+R33−R53); B33=¼*(B22+B24+B42+B44)+⅛*(R33−R31+R33−R35+R33−R13+R33−R53); wherein, R_(ij), G_(ij) and B_(ij) are the known color values of each point in the 5×5 Bayer matrix, and 1≦i, j≦5, i and j are natural numbers.
 5. A method for realizing color interpolation of value correction of exceptional points, which comprises: 1) establishing a Bayer matrix for color interpolation: a point at which interpolation is to be carried out is set as a center point to establish a 5×5 Bayer matrix, in which each point is represented by one known color and two unknown colors, the three colors being R, G, and B, and the known color of the center point is G; 2) correcting the known color value of the center point: the known color value of the center point is corrected based on the relationship of difference of the known color value of points in the matrix with the same known color as that of the center point 3) correcting the known color value of points surrounding to the center point: the known color values of two points with B as known color surrounding to the center point and two points with R as known color surrounding to the center point are corrected; 4) interpolating for the two unknown color values of the center point: average values of the corrected known color values of the two points with R or B as known color surrounding to the center point are respectively taken as estimated values for color R or B of the center point, and the estimated values are corrected with difference values between the known color value of the center point and the known color values of the surrounding points, so as to obtain the values of color R and B of the center point, respectively.
 6. The method for realizing color interpolation of value correction of exceptional points according to claim 5, wherein, in step 2) and step 3), a principle for correction is as follows: if the known color value of the center point is higher by a preset value than the known color values of surrounding points with the same known color as that of the center point, and the difference value between the known color value of the center point and the average value of the known color values of surrounding points is also higher by the preset value, then the known color value of the center point is replaced with the average value of the known color values of the surrounding points; otherwise the known color value of the center point is maintained.
 7. The method for realizing color interpolation of value correction of exceptional points according to claim 6, wherein, in the step 2), the average value is the average value of the known color values of eight points with G as known color surrounding to the center point; and in the step 3), for two points with R as known color, the average values are calculated as follows respectively: Rl=¼*(G33+G31+G22+G42) and Rr=¼*(G33+G35+G24+G44); for two points with B as known color, the average values are calculated as follows respectively: Bu=¼*(G33+G13+G22+G24) and Bd=¼*(G33+G53+G42+G44).
 8. The method for realizing color interpolation of value correction of exceptional points according to claim 7, wherein, in the step 4): the value of R of the center point is calculated as follows: R33=½*(R32+R34)+¼*(G33−Rl+G33−Rr); and the value of B of the center point is calculated as follows: B33=½*(B23+B43)+¼*(G33−Bu+G33−Bd); wherein Rl=¼*(G33+G31+G22+G42); Rr=¼*(G33+G35+G24+G44); Bu=¼*(G33+G13+G22+G24); Bd=¼*(G33+G53+G42+G44); R_(ij), G_(ij), and B_(ij) are the known color values of each point in the 5×5 Bayer matrix, and 1≦i, j≦5, i and j are natural numbers. 